package cn.fuego.busrental.ui.user;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.RelativeLayout;
import cn.fuego.busrental.R;
import cn.fuego.busrental.ui.StyleTour.ContainBusActivity;
import cn.fuego.busrental.ui.StyleTour.InfoEditActivity;
import cn.fuego.common.util.format.DateUtil;
import cn.fuego.misp.ui.base.MispBaseActivtiy;
import cn.fuego.misp.ui.common.edit.MispEditParameter;
import cn.fuego.misp.ui.common.edit.MispTextEditActivity;
import cn.fuego.misp.ui.info.MispInfoListActivity;
import cn.fuego.misp.ui.model.CommonItemMeta;
import cn.fuego.misp.ui.pop.MispPopListWindow;
import cn.fuego.misp.ui.pop.MispPopWindowListener;
import cn.fuego.misp.ui.util.DateTimePickDialogUtil;
import cn.fuego.misp.ui.util.StrUtil;

public class BasicDataActivity extends MispInfoListActivity {

	public static final String User_Name = "姓名";
	public static final String User_Body = "身份证号码";
	public static final String User_Phone = "电话";	
	private static final int REQUEST_CODE_EDIT_TEXT = 0;
	private static final int REQUEST_CODE_EDIT_ADDR = 1;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		
	}

	protected List<CommonItemMeta> getBtnData(boolean isInit)
	{			
		
		List<CommonItemMeta> list = new ArrayList<CommonItemMeta>();
				
			list.add(new CommonItemMeta(CommonItemMeta.TEXT_CONTENT, User_Name, StrUtil.noNullStr("1")));
			list.add(new CommonItemMeta(CommonItemMeta.TEXT_CONTENT, User_Body, StrUtil.noNullStr("1")));
			list.add(new CommonItemMeta(CommonItemMeta.TEXT_CONTENT, User_Phone, StrUtil.noNullStr("1")));
			
		return list;
	}
	@Override
	public void onItemListClick(AdapterView<?> parent, View view, long id,
			CommonItemMeta item)
	{
 		String title =   item.getTitle();
		MispEditParameter data = new MispEditParameter();
		data.setTilteName(title);
		data.setDataKey(title);
		if(User_Name.equals(title))
		{
			data.setDataValue((String) item.getContent());
			InfoEditActivity.jump(this, data, REQUEST_CODE_EDIT_TEXT,this.getString(R.string.disc_order_number));
		}		
		if(User_Body.equals(title))
		{
			data.setDataValue((String) item.getContent());
			InfoEditActivity.jump(this, data, REQUEST_CODE_EDIT_TEXT,this.getString(R.string.disc_order_number));
		}	
		if(User_Phone.equals(title))
		{
			data.setDataValue((String) item.getContent());
			InfoEditActivity.jump(this, data, REQUEST_CODE_EDIT_TEXT,this.getString(R.string.disc_order_number));
		}	
		
		
	}

	@Override
	protected void onActivityResult(int requestCode, int resultCode, Intent data)
	{
		
		//重载mispInfo
		super.onActivityResult(requestCode, resultCode, data);
	
		if(REQUEST_CODE_EDIT_ADDR==requestCode ||REQUEST_CODE_EDIT_TEXT == requestCode)
		{
			if(null != data)
			{
				MispEditParameter result_value = (MispEditParameter) data
						.getSerializableExtra(MispTextEditActivity.JUMP_DATA);

				if (null != result_value)
				{
					
					
					if(result_value.getDataKey().equals(User_Name)){
						
					}
					
					if(result_value.getDataKey().equals(User_Body))
					{
						Pattern pattern = Pattern.compile("[0-9]*"); 
						   Matcher isNum = pattern.matcher(result_value.getDataValue());
						   if( !isNum.matches() ){
							   showMessage("请输入正确的数字");
						   } 
						   else
						   {
							   
							  
						   }
						
					}
					
					if(result_value.getDataKey().equals(User_Phone)){
											
										}
					}
				}
			}
			this.refreshList(this.getBtnData(false));
		}
	
	@Override
	protected void initData() {
		
	}


	@Override
	protected void initView() {
		
	}


	@Override
	public void onClick(View v)
	{
		
		
	}


	@Override
	public void initRes() {
		
		this.activityRes.setAvtivityView(R.layout.activity_basic_data);
	
		
	}
	public static void jump(Context context)
	{
		Intent intent = new Intent();
		intent.setClass(context, BasicDataActivity.class);		
		context.startActivity(intent);
	}
}
